package com.example.other.controller;

import com.example.authority.common.entity.Result;
import com.example.other.domain.VO.CalendarVO;
import com.example.other.service.HospitalService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.Calendar;
import java.util.List;

@Slf4j
@RestController
public class HospitalController extends BaseController {


    @GetMapping("/hospital")
    public Result list() {
        try{
            return Result.succ(hospitalService.getList());
        }catch (Exception e){
            return Result.fail(e.getMessage());
        }
    }

    @GetMapping("/hospital/{id}")
    public Result getHospital(@PathVariable String id) {
        try{
            return Result.succ(hospitalService.getById(id));
        }catch (Exception e){
            return Result.fail(e.getMessage());
        }
    }

    @GetMapping("/hospital/calendar")
    public Result calendar(Integer hpId) {
        try{
            List<CalendarVO> calendar = calendarService.getCalendarByHospital(hpId);
            return new Result(200, "获取成功", calendar);
        }catch (Exception e){
            return Result.fail(e.getMessage());
        }
    }
}
